package com.gitee.deeround.javaprotect.agent;

import com.gitee.deeround.javaprotect.agent.util.FileUtils;
import com.gitee.deeround.javaprotect.agent.util.StringUtils;

import java.io.File;

/**
 * @author wanghao 913351190@qq.com
 * @create 2023/11/8 14:35
 */
public class P {

    private String s = "64:16:7f:7e:9e:50";

    public P(String s3) {
        this.s = s3;
        if (StringUtils.isEmpty(s)) {
            s = System.getProperty("protect.agent.key");
            if (StringUtils.isEmpty(s)) {
                s = System.getenv("protect.agent.key");
            }
            if (StringUtils.isEmpty(s)) {
                File file = new File("protect.agent.key");
                if (file.exists()) {
                    s = FileUtils.readStr(file);
                }
            }
        }
        if (StringUtils.isEmpty(s)) {
            throw new RuntimeException("Agent key is empty");
        }
    }

    public String s() {
        return s;
    }

}
